/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dialog;

import main.Demo;
import dto.Application;
import dto.ProcessAndTitle;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JDialog;
import javax.swing.JFormattedTextField;
import javax.swing.JFrame;
import javax.swing.JSpinner;
import javax.swing.ListSelectionModel;
import javax.swing.SpinnerDateModel;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.event.ListSelectionEvent;
import javax.swing.text.JTextComponent;
import jni.WindowHandles;
import org.omg.CORBA.Bounds;
import util.DateUtil;
import util.ModelTable;
import util.StringUtil;
import util.TableUtil;
import util.UserComputerUtil;
import xml.XmlFile;

/**
 *
 * @author phat10130059
 */
public class AddBlockWindow extends javax.swing.JPanel {

    /**
     * Creates new form AddBlockWindow
     */
    private JDialog dialog;
    private Demo jframe;
    private ModelTable dmodel;
    Toolkit toolkit;
    Timer timer;
    public boolean isRunning = false;
    private Application app;
    private String type;
    private String filePath;

    public AddBlockWindow(JDialog dialog, Demo jframe, String type) {
        
        
        this.jframe = jframe;
        
        creatTable();
        initComponents();

        this.dialog = dialog;
        
        this.type = type;

        this.filePath = jframe.filePath;


        if ("1".equals(type)) {
            //application title
            jComboBox1.addItem("skype");
            jComboBox1.addItem("facebook");
            jComboBox1.addItem("yahoo");
        } else if ("2".equals(type)) {
            //website
            jComboBox1.addItem(".vn");
            jComboBox1.addItem(".com");
            jComboBox1.addItem(".net");
        }


        jComboBox1.setEditable(true);
        jComboBox1.setSelectedItem("");


        initTable();

        btOk.setEnabled(false);


        final JTextComponent tcA = (JTextComponent) jComboBox1.getEditor().getEditorComponent();
        tcA.getDocument().addDocumentListener(new DocumentListener() {
            @Override
            public void insertUpdate(DocumentEvent e) {
                btOk.setEnabled(true);
            }

            @Override
            public void removeUpdate(DocumentEvent e) {
                String t = jComboBox1.getEditor().getItem().toString();
                if (t.trim().equals("")) {
                    btOk.setEnabled(false);
                }
            }

            @Override
            public void changedUpdate(DocumentEvent e) {
            }
        });


        initCBWindowUser();

        initSpinner();

        toolkit = Toolkit.getDefaultToolkit();
        timer = new Timer();
        timer.schedule(new scheduleDailyTask(), 0, 4000);

        isRunning = true;
        
        this.jframe.isRunning = false;

//        System.out.println("phat"+DateUtil.dateToString((Date)spinner1.getValue()));

    }

    public AddBlockWindow(JDialog dialog, Demo jframe, Application app, String type) {

        creatTable();
        initComponents();

        this.dialog = dialog;
        this.jframe = jframe;
        this.type = type;
        this.app = app;

        this.filePath = jframe.filePath;



        if ("1".equals(type)) {
            //application title
            jComboBox1.addItem("skype");
            jComboBox1.addItem("facebook");
            jComboBox1.addItem("yahoo");
        } else if ("2".equals(type)) {
            //website
            jComboBox1.addItem(".vn");
            jComboBox1.addItem(".com");
            jComboBox1.addItem(".net");
        }

        jComboBox1.setEditable(true);
        jComboBox1.getEditor().setItem(app.getWindow());

        jComboBox1.setSelectedItem(app.getWindow());




        initTable();

        btOk.setEnabled(true);


        final JTextComponent tcA = (JTextComponent) jComboBox1.getEditor().getEditorComponent();
        tcA.getDocument().addDocumentListener(new DocumentListener() {
            @Override
            public void insertUpdate(DocumentEvent e) {
                btOk.setEnabled(true);
            }

            @Override
            public void removeUpdate(DocumentEvent e) {
                String t = jComboBox1.getEditor().getItem().toString();
                if (t.trim().equals("")) {
                    btOk.setEnabled(false);
                }
            }

            @Override
            public void changedUpdate(DocumentEvent e) {
            }
        });

        initCBWindowUser();
        jcbWindowUser.setSelectedItem(app.getUser());

        initSpinner();
        initSpinnerEdit(app);


        toolkit = Toolkit.getDefaultToolkit();
        timer = new Timer();
        timer.schedule(new scheduleDailyTask(), 0, 4000);

        isRunning = true;
        
        this.jframe.isRunning = false;

    }

    private void initSpinner() {

        spinner1.setEnabled(false);
        spinner2.setEnabled(false);

        spinner1.setModel(new SpinnerDateModel(new Date(), null, null, Calendar.HOUR_OF_DAY));
        spinner1.setEditor(new JSpinner.DateEditor(spinner1, "h:mm:ss a"));
        JFormattedTextField tf = ((JSpinner.DefaultEditor) spinner1.getEditor()).getTextField();
        tf.setEditable(false);
        tf.setBackground(Color.white);



        spinner2.setModel(new SpinnerDateModel(new Date(), null, null, Calendar.HOUR_OF_DAY));
        spinner2.setEditor(new JSpinner.DateEditor(spinner2, "h:mm:ss a"));
        JFormattedTextField tf2 = ((JSpinner.DefaultEditor) spinner2.getEditor()).getTextField();
        tf2.setEditable(false);
        tf2.setBackground(Color.white);
    }

    private void initSpinnerEdit(Application app) {
        if (!app.getStart().trim().equals("") && !app.getEnd().trim().equals("")) {
            jCheckBox1.setSelected(true);
            spinner1.setEnabled(true);
            spinner2.setEnabled(true);

            spinner1.setValue(DateUtil.stringToDate(app.getStart()));
            spinner2.setValue(DateUtil.stringToDate(app.getEnd()));
        }
    }

    private void initCBWindowUser() {
        List<String> allUserComputer = UserComputerUtil.getAllUserComputer();
        for (String str : allUserComputer) {
            jcbWindowUser.addItem(str);
        }

    }

    private void initTable() {
        table.setShowGrid(false);
        table.setIntercellSpacing(new Dimension(0, 0));

        table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    }

    class scheduleDailyTask extends TimerTask {

        public void run() {
            if (isRunning) {
                searchAllTable();
            }
        }
    }

    private void creatTable() {

        Object rows[][] = {};
        Object headers[] = {"Title"};
        dmodel = new ModelTable(rows, headers);
        dmodel.setCanEdit(new boolean[]{false});
        dmodel.setTypes(new Class[]{String.class});
    }

    private void searchAllTable() {

        TableUtil.clearTable(dmodel);


        //get all title window
        List<ProcessAndTitle> allTitle = WindowHandles.getAllTile();


        for (int i = 0; i < allTitle.size(); i++) {
            if (allTitle.get(i).getProcessName().equals("chrome.exe")
                    || allTitle.get(i).getProcessName().equals("firefox.exe")
                    || allTitle.get(i).getProcessName().equals("iexplore.exe")) {

                String tmpTitleName = StringUtil.joinString(StringUtil.cutString(allTitle.get(i).getTitleName()));

                allTitle.get(i).setTitleName(tmpTitleName.trim());
            }
        }

        //        System.out.println(titleApp.size());


        for (ProcessAndTitle processAndTitle : allTitle) {
            dmodel.insertRow(dmodel.getRowCount(), new Object[]{
                        processAndTitle.getTitleName()
                    });
        }

    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        btOk = new javax.swing.JButton();
        btCancel = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        table = new javax.swing.JTable();
        lbWindowIsRunning = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jComboBox1 = new javax.swing.JComboBox();
        lbKeyword = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        lbUserWindow = new javax.swing.JLabel();
        jcbWindowUser = new javax.swing.JComboBox();
        jPanel4 = new javax.swing.JPanel();
        spinner1 = new javax.swing.JSpinner();
        spinner2 = new javax.swing.JSpinner();
        lbTimeFrom = new javax.swing.JLabel();
        lbTimeEnd = new javax.swing.JLabel();
        jCheckBox1 = new javax.swing.JCheckBox();

        btOk.setText("Ok");
        btOk.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btOkActionPerformed(evt);
            }
        });

        btCancel.setText(jframe.BtCancel);
        btCancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btCancelActionPerformed(evt);
            }
        });

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, jframe.BorderTextAddBlockWindow, javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 12)));

        table.setTableHeader(null);
        table.setModel(dmodel);
        table.setColumnSelectionAllowed(true);
        table.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tableMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(table);
        table.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);

        lbWindowIsRunning.setText(jframe.LbWindowIsRunning);

        jComboBox1.setMaximumSize(new java.awt.Dimension(28, 20));
        jComboBox1.setMinimumSize(new java.awt.Dimension(28, 20));

        lbKeyword.setText(jframe.LbKeyword);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lbKeyword)
                    .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(0, 12, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addComponent(lbKeyword)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jComboBox1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(23, Short.MAX_VALUE))
        );

        lbUserWindow.setText(jframe.LbUserWindow);

        jcbWindowUser.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "[All]" }));

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lbUserWindow)
                    .addComponent(jcbWindowUser, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(0, 0, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addComponent(lbUserWindow)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jcbWindowUser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        lbTimeFrom.setText(jframe.LbTimeFrom);

        lbTimeEnd.setText(jframe.LbTimeEnd);

        jCheckBox1.setText(jframe.JCheckBox1);
        jCheckBox1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBox1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lbTimeFrom)
                            .addComponent(lbTimeEnd))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(spinner2, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(spinner1, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(jCheckBox1))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGap(12, 12, 12)
                .addComponent(jCheckBox1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(spinner1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbTimeFrom))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(spinner2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbTimeEnd))
                .addContainerGap(93, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 232, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbWindowIsRunning))
                .addGap(39, 39, 39))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(13, 13, 13)
                        .addComponent(lbWindowIsRunning)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 229, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap(21, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(btOk, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(47, 47, 47)
                .addComponent(btCancel)
                .addGap(30, 30, 30))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btCancel)
                    .addComponent(btOk))
                .addContainerGap(39, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void btCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btCancelActionPerformed
        
        jframe.isRunning = true;
        
        isRunning = false;

        dialog.dispose();

    }//GEN-LAST:event_btCancelActionPerformed

    private void btOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btOkActionPerformed

        String window = (String) jComboBox1.getEditor().getItem();
        String user = (String) jcbWindowUser.getSelectedItem();

        String start = DateUtil.dateToString((Date) spinner1.getValue());
        String end = DateUtil.dateToString((Date) spinner2.getValue());

        if (app != null) {

            app.setWindow(window);
            app.setUser(user);

            if (jCheckBox1.isSelected()) {
                app.setStart(start);
                app.setEnd(end);
            } else {
                app.setStart("");
                app.setEnd("");
            }


            File fXmlFile = new File(filePath + File.separator + "file.xml");
            if (fXmlFile.exists() && !fXmlFile.isDirectory()) {
                XmlFile.editXml(filePath + File.separator + "file.xml", app);
            }


        } else {
            Application application = new Application();
            application.setUser(user);
            application.setWindow(window);

            if (jCheckBox1.isSelected()) {
                application.setStart(DateUtil.dateToString((Date) spinner1.getValue()));
                application.setEnd(DateUtil.dateToString((Date) spinner2.getValue()));
            } else {
                application.setStart("");
                application.setEnd("");
            }



            if (type.equals("1")) {
                application.setType("appTile");
            } else if (type.equals("2")) {
                application.setType("site");
            }



            File fXmlFile = new File(filePath + File.separator + "file.xml");

            if (fXmlFile.exists() && !fXmlFile.isDirectory()) {
                XmlFile.createXmlExist(filePath + File.separator + "file.xml", application);
            } else {
                XmlFile.createXmlNew(filePath + File.separator + "file.xml", application);
            }
        }






        if (type.equals("1")) {
            jframe.searchAllTable1();



        } else if (type.equals("2")) {
            jframe.searchAllTable2();
        }

        //refresh listApp
        jframe.listApp = new ArrayList<Application>();
        jframe.listApp = XmlFile.readFileXml(filePath + File.separator + "file.xml");
        
        jframe.isRunning = true;
        
        isRunning = false;

        dialog.dispose();

//        System.out.println(selectedItem);

    }//GEN-LAST:event_btOkActionPerformed

    private void tableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tableMouseClicked

        if (type.equals("1")) {
            int r = table.getSelectedRow();
            if (r > -1) {
                String title = table.getModel().getValueAt(r, 0).toString();
                jComboBox1.getEditor().setItem(title);

            }
        }


    }//GEN-LAST:event_tableMouseClicked

    private void jCheckBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox1ActionPerformed

        if (jCheckBox1.isSelected()) {
            spinner1.setEnabled(true);
            spinner2.setEnabled(true);
        } else {

            spinner1.setValue(new Date());
            spinner2.setValue(new Date());
            spinner1.setEnabled(false);
            spinner2.setEnabled(false);
        }


    }//GEN-LAST:event_jCheckBox1ActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btCancel;
    private javax.swing.JButton btOk;
    private javax.swing.JCheckBox jCheckBox1;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JComboBox jcbWindowUser;
    private javax.swing.JLabel lbKeyword;
    private javax.swing.JLabel lbTimeEnd;
    private javax.swing.JLabel lbTimeFrom;
    private javax.swing.JLabel lbUserWindow;
    private javax.swing.JLabel lbWindowIsRunning;
    private javax.swing.JSpinner spinner1;
    private javax.swing.JSpinner spinner2;
    private javax.swing.JTable table;
    // End of variables declaration//GEN-END:variables
}
